﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace INSTA.Concepts.Events
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void OnButton1_Click(object sender, EventArgs e)
        {
           
        }

        private void OnPanelMouseMove(object sender, MouseEventArgs e)
        {
            string infos = e.X + ";" + e.Y;

            Log(infos);
        }

        private void Log(string info)
        {
            txtLog.Text += info + "\r\n";
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtLog.Text = string.Empty;
        }


        /// <summary>
        /// Handles the Click event of the btnSubsscribe control
        /// and subscribe the event to the "OnPanelMouseMove" méthod
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnSubsscribe_Click(object sender, EventArgs e)
        {
            panel1.MouseMove += new MouseEventHandler(OnPanelMouseMove);
        }

        /// <summary>
        /// Handles the Click event of the btnUnsubscribe control,
        /// and unsubscribes the event from the "OnPanelMouseMove" méthod
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnUnsubscribe_Click(object sender, EventArgs e)
        {
            panel1.MouseMove -= new MouseEventHandler(OnPanelMouseMove);   

        }

       

    }
}
